<!DOCTYPE html>
<HTML>
<HEAD><meta name="viewport" content="width=device-width, initial-scale=1">
<Title>JsChartViewer.addEventListener</Title>
<link type='text/css' rel='Stylesheet' href="maxchartapi.css" />
</HEAD>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">

<p class="heading0">ChartDirector 7.0 (Java Edition)</p>
<p class="heading1"><a href="JsChartViewer.htm">JsChartViewer</a>.<wbr>addEventListener</p>
<hr class="separator">
<p class="heading2a">Usage</p>
<div class="content">
addEventListener(obj, evt, func[, useCapture])
</div>
<p class="heading2">Description</p>
<div class="content">
A utility to attach an event handler to a Javascript event.<br><br>
A Javascript event refers to Javascript events generated by the browser (as opposed to <a href="JsChartViewer.htm">JsChartViewer</a> events). An example is the "onload" event of the &lt;body&gt; tag.<br><br>
The classical way to attach an event handler to a Javascript event is to use an attribute. For example, the "onload" attribute can be used to attach a handler to the "onload" event. The disadvantage of this method is that only one event handler can be attached. It becomes difficult to manage if multiple scripts all want to programmatically attach event handlers to the same event of the same object.<br><br>
Modern browsers have special methods that allow multiple event handlers to be attached to the same event of the same object. However, the methods are different for different browsers. Some browsers use the addEventListener method, while some browsers use the attachEvent method.<br><br>
JsChartViewer.addEventListener is a utility method that calls the target object's addEventListener method if the method exists, or the attachEvent method if it does not exist. Using this method an avoid writing different code to handle different browsers.<br><br>
<div class="greyblock">
<b>Note:</b> This is a static method (class method). It should be accessed as JsChartViewer.addEventListener, not <i>objName</i>.addEventListener.
</div>
</div>
<p class="heading2">Arguments</p>
<div class="content">
<div style="width:100%;box-sizing:border-box;">
<table border="1" cellpadding="5" cellspacing="0" width="100%"> 
<tr>
<th width="19%">Argument</th><th width="19%">Default</th><th>Description</th>
</tr>
<tr>
<td>obj</td><td>(Mandatory)</td><td>The object to which the event handler is attached to.</td></tr><tr><td>evt</td><td>(Mandatory)</td><td>The name of the event, according to the Javascript addEventListener method. In this method, there is no "on" in front of the event name. For example, the event for the "onload" attribute should simply be called "load", not "onload".</td></tr><tr><td>func</td><td>(Mandatory)</td><td>A Javascript function that handles the event.</td></tr><tr><td>useCapture</td><td>(Optional)</td><td>The useCapture flag as used in the Javascript addEventListener method.</td>
</tr>
</table>
</div>
</div>
<p class="heading2">Return Value</p>
<div class="content">
None
</div>
<br><hr class="separator">
<div class="copyright">&copy; 2022 Advanced Software Engineering Limited. All rights reserved.</div>
</body>
</HTML>
